/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.idei.filetree;

import java.io.File;
import javax.swing.DropMode;
import javax.swing.JTree;
import javax.swing.TransferHandler;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeModel;

/**
 *
 * @author Emilio
 */
public class OATree extends JTree {

	private static final long serialVersionUID = 1l;
	private FileOrderStatus filesInfo;
	private File root;

	public OATree() {
		super();
	}

	public void setRoot(File root) {
		filesInfo = FileOrderStatus.read(root);
		this.root = root;
		super.setModel(new DefaultTreeModel(filesInfo.getTreeNodes()));
		super.setCellRenderer(new FileTreeRenderer());
		super.setTransferHandler(new FileNameTransferer(this, filesInfo));
		super.setDropMode(DropMode.INSERT);
		super.setDragEnabled(true);
	}

	public File getRoot() {
		return root;
	}
}
